//限流中间件
// middleware/rateLimiter.js
module.exports = async (req, res, next) => {
    try {
      await rateLimiter.consume(req.ip);
      next();
    } catch (rlError) {
      res.status(429).json({
        error: '请求过于频繁',
        retryAfter: Math.ceil(rlError.msBeforeNext / 1000)
      });
    }
  };